    {include file="head_2" title="用户列表" /}
    <div class="page-wrap">
        <div class="layui-fluid">
            <div class="layui-card">
                <div class="layui-card-body" style="padding: 15px;">
                    <div class="page_menu"><a href="/admin/users/add.html" ><button class="layui-btn layui-btn-primary">添加</button></a></div>
                    <div style="clear:both"></div>
                    <table class="layui-table" lay-data="{ url:'/admin/users/getuser_josn/', page:false, id:'idTest'}" lay-filter="demo">
                        <thead>
                            <tr>
                                <th lay-data="{field:'user', align:'center',width:150}">账号</th>
                                <th lay-data="{field:'name',align:'center', width:150}">姓名</th>
                                <th lay-data="{field:'last_time',align:'center', width:200}">最后登录时间</th>
                                <th lay-data="{field:'last_ip',align:'center', width:200}">最后登录IP</th>
                                <th lay-data="{fixed: 'right', width:120, align:'center', toolbar: '#barDemo'}">操作</th>
                            </tr>
                        </thead>
                    </table>

                </div>
            </div>
        </div>
        <script type="text/html" id="barDemo">
            <a class="layui-btn layui-btn-mini" lay-event="edit">编辑</a>
            <a class="layui-btn layui-btn-danger layui-btn-mini" lay-event="del">删除</a>
        </script>
    </div>
    <script src="{$Think.const.admin_tpl}/layui/layui.js"></script>
    <script>
        layui.use(['layer', 'table', 'jquery'], function () {
            var layer = layui.layer //弹层
                    , table = layui.table //表格
                    , $ = layui.$;

            //监听工具条
            table.on('tool(demo)', function (obj) {
                var data = obj.data
                        , layEvent = obj.event;
                if (layEvent === 'del') {
                    layer.confirm('真的删除行么', function (index) {
                        del_data(obj);
                        layer.close(index);
                        //向服务端发送删除指令
                    });
                } else if (layEvent === 'edit') {
                    location.href = "/admin/users/edit/id/" + data.id;
                }
            });
            function del_data(obj)
            {
                var data = obj.data;
                $.ajax({
                    url: "/admin/users/del_submit/",
                    type: 'post',
                    data: {id: data.id},
                    dataType: 'json',
                    success: function (data) {
                        if (data.code == 1)
                        {
                            layer.msg("删除成功!", {
                                time: 2000
                            }, function () {
                                location.reload();
                            });
                        } else
                        {
                            layer.msg(data.msg);
                        }
                    },
                });
            }

        });
    </script>

    </body>
</html>